/**
 * shp 文件解析
 */
import { read } from 'shapefile'

export const shpFileTogGeojson = (file: File) => {
  return new Promise((resolve) => {
    const reader = new FileReader()
    reader.onload = async (e: ProgressEvent<FileReader>) => {
      const arrayBuffer = e.target?.result
      const geojson = await read(arrayBuffer)
      resolve(geojson)
    }
    reader.readAsArrayBuffer(file)
  })
}
